<?php
	class reminderControl extends skymvc{
		
		public function __construct(){
			parent::__construct();
		}
		
		public function onDefault(){
			
		}
		
		public function onJs(){
			$tablename=get('tablename','h');
			$shopid=get('shopid','i');
			$data=M("reminder")->select(array(
				"where"=>"shopid=".$shopid." AND tablename='".$tablename."' ",
				"limit"=>10
			));
			 
			$this->smarty->assign(array(
				"data"=>$data
			));
			$html=$this->smarty->fetch("reminder/js.html");
			echo strtojs($html);
		}
		
		public function onGo(){
			$id=get('id','i');
			$row=M("reminder")->selectRow("id=".$id);
			M("reminder")->delete(" tablename='".$row['tablename']."' AND shopid=".$row['shopid']." AND order_id=".$row['order_id']);
			switch($row['tablename']){
				case "shop_order":
						$url="shopadmin.php?m=shop_order&a=show&order_id=".$row['order_id'];
					break;
				case "koudai_order":
						$url="koudaiadmin.php?m=koudai_order&a=show&order_id=".$row['order_id'];
					break;
				case "ymdian_order":
						$url="ymdianadmin.php?m=ymdian_order&a=show&order_id=".$row['order_id'];
					break;
			}
			header("Location: ".$url);
		}
		public function onSave(){
			M("login")->checkLogin();
			$userid=M("login")->userid;
			$data=M("reminder")->postData();
			$data['userid']=$userid;
			$row=M("reminder")->selectRow(array(
				"where"=>$data,
				"order"=>"id DESC"
			));
			if(time()-$row['dateline']<60){
				$this->goAll("请稍等",1);
			}
			
			
			$data['dateline']=time();
			M("reminder")->insert($data);
			$this->goAll("催单成功");
		}
		
		
	}
?>